<?php
class info_song extends Model{
	public static function getTableName(){
		return 'info_song';
	}

	public function set($object){
		$this->episode_id = !isset($object->episode_id) ? '0' : $object->episode_id;
		$this->title_chinese = !isset($object->title_chinese) ? '' : trim($object->title_chinese);
		$this->title_english = !isset($object->title_english) ? '' : trim($object->title_english);
		$this->genre = !isset($object->genre) ? '0' : $object->genre;
		$this->singers = !isset($object->singers) ? '' : $object->singers;
		$this->group_names = !isset($object->group_names) ? '' : $object->group_names;
		$this->producers = !isset($object->producers) ? '' : $object->producers;
		$this->composers = !isset($object->composers) ? '' : $object->composers;
		$this->lyricists = !isset($object->lyricists) ? '' : $object->lyricists;
		$this->arrangers = !isset($object->arrangers) ? '' : $object->arrangers;
		$this->record_company = !isset($object->record_company) ? '' : $object->record_company;
		$this->year = !isset($object->year) ? '0' : $object->year;
		$this->lyrics = !isset($object->lyrics) ? '' : $object->lyrics;
		$this->owners = !isset($object->owners) ? '' : $object->owners;
        $this->publish_datetime = !isset($object->publish_datetime) ? '' : $object->publish_datetime;
        $this->expire_datetime = !isset($object->expire_datetime) ? '' : $object->expire_datetime;
		$this->status = !isset($object->status) ? '0' : $object->status;
		$this->created_by = !isset($object->created_by) ? '' : $object->created_by;
		$this->created_at = !isset($object->created_at) ? '' : $object->created_at;
		$this->modified_by = !isset($object->modified_by) ? '' : $object->modified_by;
		$this->modified_at = !isset($object->modified_at) ? '' : $object->modified_at;
		$this->description = !isset($object->description) ? '' : $object->description;
	}

	/*
	 * by donald
	 */
	public function add_change_log()
	{
		$field['type'] = $this->getTableName();
		$field['keys'] = array('id' => $this->id);
		$field['is_active'] = 1;
		$field['programme_id'] = 0;
		$field['episode_id'] = $this->episode_id;
		$field['is_publish'] = 0;

		change_log::updateOne($field);
	}

	/*
	 * by donald
	 */
	public function delete_change_log()
	{
		$type = $this->getTableName();
		$keys = array('id' => $this->id);
		$is_publish = 0;

		change_log::delTypeAndKeysLog($type, $keys, $is_publish);
	}
}
?>
